package com.simon.train.business.controller.admin;


import com.simon.train.business.dto.DailyTrainCarriageQueryDto;
import com.simon.train.business.dto.DailyTrainCarriageSaveDto;
import com.simon.train.business.service.DailyTrainCarriageService;
import com.simon.train.business.vo.DailyTrainCarriageQueryVO;
import com.simon.train.common.Result.Result;
import com.simon.train.common.vo.PageVO;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/dailyTrainCarriage")
public class DailyTrainCarriageAdminController {

    @Resource
    private DailyTrainCarriageService dailyTrainCarriageService;

    @PostMapping("/save")
    public Result<Object> SaveDailyTrainCarriage(@Valid @RequestBody DailyTrainCarriageSaveDto dailyTrainCarriageSaveDto){
        dailyTrainCarriageService.SaveDailyTrainCarriage(dailyTrainCarriageSaveDto);
        return new Result<>();
    }

    @GetMapping("/queryList")
    public Result<PageVO<DailyTrainCarriageQueryVO>> DailyTrainCarriageQueryList(@Valid DailyTrainCarriageQueryDto dailyTrainCarriageQueryDto){
         /**
         * businessId通过线程变量获取 从而不需要由前端传入 保证了效率和安全性
         */
        PageVO<DailyTrainCarriageQueryVO> lists = dailyTrainCarriageService.QueryDailyTrainCarriageList(dailyTrainCarriageQueryDto);
        return new Result<>(lists);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Object> DeleteDailyTrainCarriage(@PathVariable("id") Long id){
        dailyTrainCarriageService.deleteDailyTrainCarriage(id);
        return new Result<>();
    }

}
